package com.wit.action;

import java.util.List;

import com.opensymphony.xwork2.ActionSupport;
import com.wit.po.Mark;
import com.wit.service.MarkService;

@SuppressWarnings("serial")
public class MarkAction extends ActionSupport{
	
	private Mark mark;
	
	private MarkService markService;

	private String msg;
	
	private List<Mark> markList;

	public String getMsg() {
		return msg;
	}

	public List<Mark> getMarkList() {
		return markList;
	}

	public void setMarkList(List<Mark> markList) {
		this.markList = markList;
	}
	
	public Mark getMark() {
		return mark;
	}

	public void setMark(Mark mark) {
		this.mark = mark;
	}

	public MarkService getMarkService() {
		return markService;
	}

	public void setMarkService(MarkService markService) {
		this.markService = markService;
	}
	
	public String addMark(){
		System.out.println("in addmark...."+mark.getMarkId());
		if(markService.addMark(mark))
			msg = "add Successfully";
		else
			msg = "addFailed";
		return "addPage";
	}
	
	public String deleteMark(){
		System.out.println("in deletemark...."+mark.getMarkId());
		mark = markService.findByIndentifier(mark.getMarkId());
		if(markService.deleteMark(mark))
			msg = "delete Successfully";
		else
			msg = "delete Failed";
		markList = markService.findAllMark();
		return "listPage";
	}
	
	public String modifyMark(){
		System.out.println("in modifymark...."+mark.getMarkId());
		if(markService.modifyMark(mark))
			msg = "modify Successfully";
		else
			msg = "modify Failed";
		return "modifyPage";
	}

	public String findAllMark(){
		System.out.println("in findallmark....");
		markList = markService.findAllMark();
		System.out.println(markList.size());
		return "listPage";
	}
	
	public String findMark(){
		System.out.println("in findmark...."+mark.getMarkId());
		mark = markService.findByIndentifier(mark.getMarkId());
		return "modifyPage";
	}
}
